const setProp = (dom, key, value) => {
  if (/^on/.test(key)) {
    dom[key.toLowerCase()] = value;
  } else if (key === 'style') {
    for (let key in value) {
      dom.style[key] = value[key];
    }
  } else {
    dom.setAttribute(key, value);
  }
};
export const setProps = (dom, oldProps, newProps) => {
  for (let key in oldProps) {
    if (key !== 'children') {
      if (newProps.hasOwnProperty(key)) {
        // 更新属性
        setProp(dom, key, newProps[key]);
      } else {
        dom.removeAttribute(key);
      }
    }
  }

  for (let key in newProps) {
    if (key !== 'children') {
      if (!oldProps.hasOwnProperty(key)) {
        // 添加属性
        setProp(dom, key, newProps[key]);
      }
    }
  }
};
